﻿Imports Lourdes.BackEnd
Imports Lourdes.BackEnd.BC
Imports Lourdes.BackEnd.Modelo
Public Class frmAfi
  Inherits System.Web.UI.Page

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Not IsPostBack Then
      ConfigurarControles()
      GridCargar()
    End If
  End Sub

  Private Sub ConfigurarControles()
    Dim objBC_Persona As New BC_Persona
    Dim lstOS As List(Of Persona) = objBC_Persona.getAllObraSocial
    Utils.LoadDropDownList(cmbObraSocial, lstOS, "Nombre", "PersonaId", True)
  End Sub

  Private Sub GridCargar()
    Dim objBc_Persona As New BC_Persona
    Dim strNombre As String = txtApe.Text.Trim
    Dim strDni As String = txtCodigo.Text.Trim
    Dim strNroAfi As String = txtNroAfiliado.Text.Trim
    Dim intOsPerId As Integer?
    If IsNumeric(cmbObraSocial.SelectedValue) Then
      intOsPerId = CInt(cmbObraSocial.SelectedValue)
    End If
    With grdAfi
      .DataSource = objBc_Persona.getAfiliados(strNombre, intOsPerId, strDni, strNroAfi)
      .DataBind()
    End With
    GridViewGroupHelper.GroupGridView(grdAfi.Rows, 0, 2)
  End Sub

  Private Sub btnFiltrar_Click(sender As Object, e As System.EventArgs) Handles btnFiltrar.Click
    GridCargar()
  End Sub

  Private Sub grdAfi_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdAfi.RowDataBound
    If e.Row.RowType = DataControlRowType.Header Then
      e.Row.Cells(0).Text = "Cliente"
      e.Row.Cells(1).Text = "Obra Social"
      e.Row.Cells(2).Text = "Plan Médico"
      e.Row.Cells(3).Text = "Número de Afiliado"
    End If
  End Sub

End Class